package com.carsys.controller;
import com.carsys.dto.ActionResult;
import com.carsys.entity.City;
import com.carsys.service.CarCityService;
import com.carsys.vo.VCity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class CarCityController {

@Autowired
private CarCityService carCityService;

    /**
     * 根据父id查询城市
     * @param pid
     * @return ActionResult
     */
    @RequestMapping(value="/getCities",method= RequestMethod.GET)
    public ActionResult findCityByPid(int pid){
        List<City> cities = carCityService.findCitiesByPid(pid);
        System.out.println(cities);
        ActionResult result = new ActionResult(200, null, cities);
        return result;
    }

    /**
     * 根据出发id和还车id查询城市
     * @param getid
     * @param backid
     * @return ActionResult
     */
    @RequestMapping(value="/getCity",method= RequestMethod.GET)
    public ActionResult findCity(int getid,int backid){
        VCity city = carCityService.findCitiy(getid,backid);
        ActionResult result = new ActionResult(200, null, city);
        return result;
    }


}
